<template>
  <div>
    <el-upload
      action="http://localhost:8088/uploadpacture"
      list-type="picture-card"
      :on-success="shopMainIdentityImgSuccess"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove">
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>
<script>
export default {
  data () {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
      AddForm: {
        imageUrl: ''
      }
    }
  },
  methods: {
    handleRemove (file, fileList) {
      this.AddForm.imageUrl = this.AddForm.imageUrl.replace(',' + file.response.data, '')
      console.log(this.AddForm.imageUrl)
    },
    handlePictureCardPreview (file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    shopMainIdentityImgSuccess (res, file) {
      this.dialogImageUrl = URL.createObjectURL(file.raw)
      if (res.status === 200) {
        // 字符串保存
        this.AddForm.imageUrl = this.AddForm.imageUrl + ',' + (res.data)
        console.log(this.AddForm.imageUrl)
      }
    }
  }
}
</script>
